/**
 * @type {String}
 *
 * @properties={typeid:35,uuid:"96C634E9-66AF-418F-85E2-94BC08A6A0FF"}
 */
var fMap = null;

/**
 * @type {String}
 *
 * @properties={typeid:35,uuid:"23F48277-854C-468F-9772-66BABC3199F0"}
 */
var fConsulta = null;

/**
 * @type {String}
 *
 * @properties={typeid:35,uuid:"79479BEA-AE7A-4FC3-B173-CDE1EB8A642E"}
 */
var fTelefono = null;

/**
 * @type {String}
 *
 * @properties={typeid:35,uuid:"93C79943-C525-485E-85CB-B18F0C66ACC1"}
 */
var fMail = null;

/**
 * @type {String}
 *
 * @properties={typeid:35,uuid:"AFB7201B-9CB9-4D40-851F-3851F4166BC6"}
 */
var fNombre = null;

/**
 * @properties={typeid:35,uuid:"EBF585F7-C65B-49AC-BF37-8B33BDB5EC56",variableType:-4}
 */
var fRedSocial = null;

/**
 * @properties={typeid:35,uuid:"4E27AA31-4E86-4F12-977E-173F120BEACA",variableType:-4}
 */
var fAfip = null;

/**
 * Perform the element default action.
 *
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"8B81C9D4-FD1F-4DBA-8B87-D6EA4C550BAE"}
 */
function sitioWeb(event) {
	iraSitio('http://'+ghotel_to_hoteles.direccion_web)
}

/**
 * @properties={typeid:24,uuid:"EDA6FE49-6FCF-4AA3-B654-764D6DBC1278"}
 */
function onLoad() {
//	fAfip = '<html><a href="' + ghotel_to_hoteles.link_afip + '" target="_F960AFIPInfo"><img src="media:///DATAWEB.jpg" border="0" height="75" width="60"></a></html>';
	var $frm = solutionModel.getForm('home_pie')
	dibujarRedesSociales($frm)
	dibujarMapa($frm)
	if (ghotel_to_hoteles.link_afip != null)
		elements.img_afip.visible = true
}

/**
 * @param {JSForm} $frm
 *
 * @properties={typeid:24,uuid:"C57EA7FA-FF1A-47F6-AD39-E9809319EB89"}
 */
function dibujarMapa($frm) {
	var $map = 'map'
	elements.tab_map.removeAllTabs()
	if (solutionModel.getForm($map) == null)
	{
		var $direccion = ghotel_to_hoteles.direccion + ',' + ghotel_to_hoteles.hoteles_to_regiones.descripcion + ',' + ghotel_to_hoteles.hoteles_to_paises.descripcion
		fMap = globals.buscargMapa($direccion, ghotel_to_hoteles.nombre_fantasia, ghotel_to_hoteles.nombre_fantasia, $map, 95, 345)
	}
	elements.tab_map.addTab($map)
}
/**
 * @param {JSForm} $frm
 * 
 * @properties={typeid:24,uuid:"41323195-D21A-4997-AFD5-7F3403D177CE"}
 */
function dibujarRedesSociales($frm)
{
	var $soc 		= ghotel_to_hoteles.hoteles_to_hoteles_social
	var $cant 		= $soc.getSize()
	var xInicial 	= 750
	var yInicial	= 38
	
	var $var = $frm.getVariable('fRed'+1)
	var j = 1
	while ($var != null)
	{
		$frm.removeLabel('fRed'+j)
		$frm.removeLabel('lbl_fRed'+j)
		j++
		$var = $frm.getVariable('fRed'+j)
	}
	
	for (var i = 1 ; i <= $cant ; i++)
	{
		if ( i == 1 && $frm.getLabel('lbl_social') == null)
		{
			var $lbl = $frm.newLabel(i18n.getI18NMessage('hoteleria.social'),830,6,80,20)
			$lbl.styleClass = 'titulo_blanco'
			$lbl.name		= 'lbl_social'
			var $raya = solutionModel.cloneComponent('rayita_social', $frm.getComponent('rayita'))
			$raya.x = 750
		}
		var $rcd = $soc.getRecord(i)
		var $var = $frm.getVariable('fRed'+i)
		if ($var == null)
			$var = $frm.newVariable('fRed'+i, JSVariable.MEDIA)
		forms.home_pie[$var.name] = $rcd.hoteles_social_to_redes_sociales.logo

		var $lbl = $frm.newLabel('', xInicial, yInicial + ((i-1)*28) , 26, 26)
		$lbl.toolTipText 	= $rcd.direccion
		$lbl.name 			= 'fRed'+i
		$lbl.dataProviderID = $var.name	
		$lbl.rolloverCursor = SM_CURSOR.HAND_CURSOR
		$lbl.showClick 		= false
		$lbl.showFocus 		= false
		$lbl.onAction 		= $frm.getMethod('iraRedSocial')
		
		var $lbl = $frm.newLabel($rcd.direccion, xInicial + 30, yInicial + ((i-1)*28) , 300, 15)
		$lbl.toolTipText 	= $rcd.direccion
		$lbl.name 			= 'lbl_fRed'+i
		$lbl.rolloverCursor = SM_CURSOR.HAND_CURSOR
		$lbl.showClick 		= false
		$lbl.showFocus 		= false
		$lbl.onAction 		= $frm.getMethod('iraRedSocial')
		$lbl.styleClass		= 'letrachica_blanco'
	}
	forms.home_pie.controller.recreateUI()

}

/**
 * Perform the element default action.
 *
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"DC714CAD-838C-4A9F-A720-2073A184D951"}
 */
function iraAfip(event) {
	iraSitio(ghotel_to_hoteles.link_afip)
}

/**
 * @param {JSEvent} event
 *
 * @properties={typeid:24,uuid:"A64C699E-CCD9-40B7-8D6B-CDDF01DFFA79"}
 */
function iraRedSocial(event)
{
	var $elm = event.getElementName()
	iraSitio(elements[$elm].toolTipText)
}

/**
 * @param {String} sitio
 * 
 * @properties={typeid:24,uuid:"1071C51C-1F01-4E17-8028-18DEEF1E6017"}
 */
function iraSitio(sitio)
{
	application.showURL(sitio)
}
/**
 * Perform the element default action.
 *
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"400F025D-E112-4F6B-997D-96AAC5216F7C"}
 */
function borrar(event) {
	fConsulta = null
	fMail     = null
	fNombre   = null
	fTelefono = null
}

/**
 * Perform the element default action.
 *
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"CEA5AE56-4C39-4508-A984-81287F4C70E0"}
 */
function enviar(event) {
	if (fConsulta != null && fMail != null && fNombre != null && fTelefono != null)
		globals.DIALOGS.showInfoDialog(i18n.getI18NMessage('hoteleria.aviso'),i18n.getI18NMessage('hoteleria.emailEnviado'),'OK')
	else
		globals.DIALOGS.showWarningDialog(i18n.getI18NMessage('hoteleria.aviso'),i18n.getI18NMessage('hoteleria.aviso.llenarDatos'),'OK')
}
